﻿#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

#endregion


namespace ESF.DMS.FileSynchronizator.Config
{
	[ConfigurationCollection(typeof(SynchronizedDirectoryElement))]
	public class SynchronizedDirectoriesCollection : ConfigurationElementCollection
	{
		#region Propiedades

		public SynchronizedDirectoryElement this[int index]
		{
			get
			{
				return (SynchronizedDirectoryElement)BaseGet(index);
			}
			set
			{
				if (BaseGet(index) != null)
					BaseRemoveAt(index);

				BaseAdd(index, value);
			}
		}


		new public SynchronizedDirectoryElement this[string Name]
		{
			get
			{
				return (SynchronizedDirectoryElement)BaseGet(Name);
			}
		}

		#endregion


		#region Funciones



		public int IndexOf(SynchronizedDirectoryElement url)
		{
			return BaseIndexOf(url);
		}


		public void Add(SynchronizedDirectoryElement url)
		{
			BaseAdd(url);
		}


		protected override void BaseAdd(ConfigurationElement element)
		{
			BaseAdd(element, false);
		}


		public void Remove(SynchronizedDirectoryElement pCnnTestElem)
		{
			if (BaseIndexOf(pCnnTestElem) >= 0)
				BaseRemove(pCnnTestElem.name);
		}


		protected override ConfigurationElement CreateNewElement()
		{
			return new SynchronizedDirectoryElement();
		}


		protected override object GetElementKey(ConfigurationElement pElement)
		{
			return ((SynchronizedDirectoryElement)pElement).name;
		}

		#endregion
	}
}
